<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24">
        <el-tabs style="width: 100%" type="border-card" v-model="activeTab">
          <el-tab-pane label="基本资料" name="userinfo">
            <div style="width: 20%;">
              <div class="el-form-item__label" style="font-weight: 700;margin-left: 10px">头像</div>
              <div style="margin-left: 100px">
                <userAvatar :user="user"/>
              </div>
            </div>
            <userInfo :role-group="roleGroup" :user="user"/>
          </el-tab-pane>
          <el-tab-pane label="修改密码" name="resetPwd">
            <resetPwd/>
          </el-tab-pane>
          <el-tab-pane label="第三方帐号绑定" name="thirdParty">
            <thirdParty :auths="auths"/>
          </el-tab-pane>
        </el-tabs>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import userAvatar from "./userAvatar";
import userInfo from "./userInfo";
import resetPwd from "./resetPwd";
import thirdParty from "./thirdParty";
import {getUserProfile} from "@/api/system/user";

export default {
  name: "Profile",
  components: {userAvatar, userInfo, resetPwd, thirdParty},
  data() {
    return {
      user: {
        dept: {
          deptName: "",
        },
      },
      roleGroup: "",
      postGroup: {},
      auths: [],
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
        this.auths = response.auths;
      });
    }
  }
};
</script>
